﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SISGEZATBZVisual.BusinessEntities;

namespace SISGEZATBZVisual.Repository
{
    public class GradoMap:EntityTypeConfiguration<Grado>
    {
        public GradoMap()
        {
            this.HasKey(r => r.Id);

            //propiedades
            this.Property(r => r.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(r => r.DescripcionGrado)
                .IsOptional().HasMaxLength(255);

            this.Property(r => r.NombreGrado)
               .IsRequired().HasMaxLength(70);


            
            
            //table
            this.ToTable("Grado");

            //Relaciones
            //this.HasRequired(r => r.Promocion)
            //    .WithMany()
            //    .HasForeignKey(r => r.IdPromocion)
            //    .WillCascadeOnDelete(false);

            this.HasRequired(r => r.Nivel)
                .WithMany()
                .HasForeignKey(r => r.IdNivel)
                .WillCascadeOnDelete(false);




        }
    }
}
